package com.biz.primus.ms.coupon.trans;

import com.biz.primus.ms.coupon.dao.po.Coupon;
import com.biz.primus.ms.coupon.dao.po.CouponType;
import com.biz.primus.ms.coupon.dao.ro.CouponRo;
import com.google.common.base.Function;

/**
 * 转换器: CouponRo --> Coupon
 *
 * @author david-liu
 */
public class CouponRo2Coupon implements Function<CouponRo, Coupon> {

    private CouponType couponType;

    public CouponRo2Coupon(CouponType couponType) {
        this.couponType = couponType;
    }

    @Override
    public Coupon apply(CouponRo couponRo) {
        Coupon coupon = new Coupon();
        coupon.setId(couponRo.getId());
        coupon.setCouponAcquireApproach(coupon.getCouponAcquireApproach());
        coupon.setCouponType(couponType);
        coupon.setCouponState(couponRo.getCouponState());
        coupon.setReceivedTime(couponRo.getReceivedTime());
        coupon.setUsed(couponRo.getUsed());
        coupon.setCreateTimestamp(couponRo.getCreateTimestamp());
        coupon.setUpdateTimestamp(couponRo.getUpdateTimestamp());
        coupon.setUseTime(couponRo.getUseTime());
        return coupon;
    }
}
